package basisApi

import (
	"github.com/Sir-yuChen/funAnalyse/model"
	"github.com/Sir-yuChen/funAnalyse/model/common/response"
	"github.com/Sir-yuChen/funAnalyse/utils"
	"github.com/gin-gonic/gin"
	"github.com/gin-gonic/gin/binding"
)

type StockMenuController struct{}

// GetStockMenuTree 多条件查询
// @Summary 菜单树
// @Tags 菜单功能相关
// @Accept application/json
// @Produce application/json
// @Param data body model.StockMenuModel true "请求参数"
// @response 200 {object} response.Response  "接口返回信息"
// @Router /funAnalyse/menu/getStockMenuTree [GET]
func (b *StockMenuController) GetStockMenuTree(c *gin.Context) {
	apiReturn := stockMenuService.GetStockMenuTree()
	response.WithApiReturn(apiReturn, c)
	return
}

// GetStockMenu 多条件查询
// @Summary stockMenu get
// @Tags 菜单功能相关
// @Accept application/json
// @Produce application/json
// @Param data body model.StockMenuModel true "请求参数"
// @response 200 {object} response.Response  "接口返回信息"
// @Router /funAnalyse/menu/getMenuInfo [GET]
func (b *StockMenuController) GetStockMenu(c *gin.Context) {
	var req model.StockMenuModel
	if err := c.ShouldBindBodyWith(&req, binding.JSON); err != nil {
		utils.ErrValidatorResp(err, "GetStockMenu", req, c)
		return
	}
	apiReturn := stockMenuService.GetStockMenu(&req)
	response.WithApiReturn(apiReturn, c)
	return
}

// InsertStockMenu
// @Summary stockMenu insert
// @Tags 菜单功能相关
// @Accept application/json
// @Produce application/json
// @Param data body model.StockMenuModel true "请求参数"
// @response 200 {object} response.Response  "接口返回信息"
// @Router /funAnalyse/menu/insertMenu [POST]
func (b *StockMenuController) InsertStockMenu(c *gin.Context) {
	var req model.StockMenuModel
	if err := c.ShouldBindJSON(&req); err != nil {
		utils.ErrValidatorResp(err, "InsertStockMenu", req, c)
		return
	}
	apiReturn := stockMenuService.InsertStockMenu(&req, c)
	response.WithApiReturn(apiReturn, c)
	return
}

// UpdateStockMenu
// @Summary stockMenu update
// @Tags 菜单功能相关
// @Accept application/json
// @Produce application/json
// @Param data body model.StockMenuModel true "请求参数"
// @response 200 {object} response.Response  "接口返回信息"
// @Router /funAnalyse/menu/updateMenuInfo [POST]
func (b *StockMenuController) UpdateStockMenu(c *gin.Context) {
	var req model.StockMenuModel
	if err := c.ShouldBindBodyWith(&req, binding.JSON); err != nil {
		utils.ErrValidatorResp(err, "UpdateStockMenu", req, c)
		return
	}
	apiReturn := stockMenuService.UpdateStockMenu(&req)
	response.WithApiReturn(apiReturn, c)
	return
}

// DelStockMenu
// @Summary stockMenu del
// @Tags 菜单功能相关
// @Accept application/json
// @Produce application/json
// @Param data body model.StockMenuModel true "请求参数"
// @response 200 {object} response.Response  "接口返回信息"
// @Router /funAnalyse/menu/delMenu [Get]
func (b *StockMenuController) DelStockMenu(c *gin.Context) {
	var req model.StockMenuModel
	if err := c.ShouldBindBodyWith(&req, binding.JSON); err != nil {
		utils.ErrValidatorResp(err, "DelStockMenu", req, c)
		return
	}
	apiReturn := stockMenuService.DelStockMenu(&req)
	response.WithApiReturn(apiReturn, c)
	return
}
